<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta charset="utf-8">
		<title>商品自动匹配-手动关联</title>
		<meta name="description" content="overview &amp; stats">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/bootstrap.css">
		<link rel="stylesheet" href="${request.contextPath}/static/assets/font-awesome/4.5.0/css/font-awesome.min.css">
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/daterangepicker.min.css">
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/jquery.css">
		<!-- text fonts -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/fonts.css">
		<!-- ace styles -->
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style">
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace-skins.min.css">
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace-rtl.min.css">
		<!-- ace settings handler -->
		<script src="${request.contextPath}/static/assets/js/ace-extra.min.js"></script><style>@keyframes nodeInserted{from{outline-color:#fff}to{outline-color:#000}}@-moz-keyframes nodeInserted{from{outline-color:#fff}to{outline-color:#000}}@-webkit-keyframes nodeInserted{from{outline-color:#fff}to{outline-color:#000}}@-ms-keyframes nodeInserted{from{outline-color:#fff}to{outline-color:#000}}@-o-keyframes nodeInserted{from{outline-color:#fff}to{outline-color:#000}}.ace-save-state{animation-duration:10ms;-o-animation-duration:10ms;-ms-animation-duration:10ms;-moz-animation-duration:10ms;-webkit-animation-duration:10ms;animation-delay:0s;-o-animation-delay:0s;-ms-animation-delay:0s;-moz-animation-delay:0s;-webkit-animation-delay:0s;animation-name:nodeInserted;-o-animation-name:nodeInserted;-ms-animation-name:nodeInserted;-moz-animation-name:nodeInserted;-webkit-animation-name:nodeInserted}</style>
		<script src="${request.contextPath}/static/assets/js/jquery-2.1.4.min.js"></script>	
		<link rel="stylesheet" href="${request.contextPath}/static/assets/css/bsie-paginator.css">
		<style type="text/css">
			#deleteRemind{
				width:400px
			}
			#linkCommodityModal{
				width:650px
			}
			
			
			.backcolor{background-color: #D3FAD5!important;}
		</style>
	</head>

	<body class="skin-2" id="top" style="background-color: #FFF;">
		<div class="page-content" style="padding: 2px 2px 0px;">
		  <div class="tabbable">
			<div class="tab-content">
				<div id="manage" class="tab-pane active in">
					<!-- 筛选条件开始 -->
					<div class="row">
						<div class="col-sm-12">
							<div style="padding-right: 10px;">
								<span class="label label-xlg label-success arrowed-right" id="returnToMatchPage"  style="cursor: pointer;"   onclick="skip('${request.contextPath}/match/ticket/commodity/list?page=<#if paramCommoItem.rsrvStr1??>${paramCommoItem.rsrvStr1}<#else>0</#if>&companyCode=${paramCommoItem.companyCode!}&commodityId=${paramCommoItem.commodityId!}&commodityName=${paramCommoItem.predealName!}&productName=${paramCommoItem.productName!}');">返回</span>
								<#if lmmCommoditySortType?? && lmmCommoditySortType!=''>
									<span class="label label-lg label-yellow arrowed-in arrowed-in-right" style="cursor: pointer;" onclick="commodityNameSortClick()">按最优景点名称排序</span>
								<#else>
									<span class="label label-lg label-yellow arrowed-in arrowed-in-right" style="cursor: pointer;" onclick="priceSortClick()">按价格排序</span>
								</#if>
								<span class="label label-xlg label-purple arrowed"  style="cursor: pointer;"  data-toggle="modal"   onclick="noCommodityMatch();">无商品可关联</span>
							</div>
							<div class="widget-box">
								<div class="widget-header">
									<h4 class="widget-title lighter">
										<i class="ace-icon fa"></i><#if paramCommoItem.commodityName??>${paramCommoItem.commodityName}</#if><#if paramCommoItem.price??>(￥${paramCommoItem.price})</#if>
									</h4>
								</div>
								<form class="form-inline" id="searchForm" 
								action="${request.contextPath}/match/ticket/commodity/rel/listLmmCommodity" method="post">
									<input type="hidden" id="_csrf" name="${_csrf.parameterName}" value="${_csrf.token}"/>
									<input type="hidden" id="commodityUuidId" name="id" value="${paramCommoItem.id}"/>
									<input type="hidden" name="commodityId"  value="${paramCommoItem.commodityId}"/>
									<!-- 公司名称 -->
									<input type="hidden" name="companyCode" value="${paramCommoItem.companyCode}"/>
									<!-- 查询名称 -->
									<input type="hidden" name="predealName"  value="${paramCommoItem.predealName}"/>
									<input type="hidden" name="productName"  value="${paramCommoItem.productName}"/>
									<input type="hidden" name="rsrvStr1" value="${paramCommoItem.rsrvStr1}"  />
									<input type="hidden" id="currentLinkedLvmmCommodityId" name="rsrvStr2" value="${paramCommoItem.rsrvStr2}"  />
									<!--   该标识用来表明对驴妈妈商品使用价格排序  -->
									<input type="hidden" name="lmmCommoditySortType" id="lmmCommoditySortType" value="${lmmCommoditySortType!}"  />
								</form>
							</div>
						</div>
					<!-- 筛选条件结束 -->
				    <!-- tab开始 -->
					 <div class="col-xs-12"  id="codeList">
						<#if lvmmList??>
						<table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dynamic-table_info">
							<thead>
								<tr>
									<th>监控平台</th>
									<th>监控景区</th>
									<th>商品编号</th>
									<th>商品名称</th>
									<th>价格</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<#if lvmmList?? && lvmmList?size&gt;0> 
							      	<#list  lvmmList as commodity>
											<tr>
										    <td <#if paramCommoItem.rsrvStr2?? && paramCommoItem.rsrvStr2==commodity.commodityId>class="backcolor"</#if> class="companyCode">${commodity.companyCode!}</td>
											<td <#if paramCommoItem.rsrvStr2?? && paramCommoItem.rsrvStr2==commodity.commodityId>class="backcolor"</#if> class="productName">${commodity.productName!}</td>
										    <td <#if paramCommoItem.rsrvStr2?? && paramCommoItem.rsrvStr2==commodity.commodityId>class="backcolor"</#if> class="commodityId">${commodity.commodityId!}</td>
											<td  <#if paramCommoItem.rsrvStr2?? && paramCommoItem.rsrvStr2==commodity.commodityId>class="backcolor"</#if> class="commodityName">${commodity.commodityName}</td>
										    <td <#if paramCommoItem.rsrvStr2?? && paramCommoItem.rsrvStr2==commodity.commodityId>class="backcolor"</#if> class="price">￥${commodity.price!}</td>
											<td  <#if paramCommoItem.rsrvStr2?? && paramCommoItem.rsrvStr2==commodity.commodityId>class="backcolor"</#if>>
												<#if paramCommoItem.rsrvStr2?? && paramCommoItem.rsrvStr2==commodity.commodityId>
													<!-- <input type="radio" name="lvmmcommoRadio" value="${commodity.commodityId!}" checked="checked"/> -->
													<span class="label label-lg"  style="cursor: pointer;"  onclick="">已关联</span>
												<#else>
													<span class="label label-lg label-pink"  style="cursor: pointer;"  onclick="dealCommodityMatch(this);" data-value="${commodity.commodityId!}">关联</span>
													<!-- <input type="radio" name="lvmmcommoRadio" value="${commodity.commodityId!}"/> -->
												</#if>
												<input type="hidden" class="lvProductId" value="${commodity.lvProductId!}" />
												<input type="hidden" class="lvCommodityName" value="${commodity.lvCommodityName!}" />
												<input type="hidden" class="monitorId" value="${commodity.monitorId!}" />
												<input type="hidden" class="id" value="${commodity.id!}" />
												<input type="hidden" class="commodityName" value="${commodity.commodityName!}" />
												<input type="hidden" class="productUrl" value="${commodity.productUrl!}" />
											</td>
										</tr>
							    	</#list>
								</#if>	
							</tbody>
						</table>
						</#if>
						<#include "/paginator.html">
				</div>
			</div>
		</div>
	</div>
	</div>
	</div>
		
		
		
		
		
		<input type="hidden" id="matchLinkContext" value="${request.contextPath}"/>
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) 
				document.write("<script src='${request.contextPath}/static/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
			
		</script>
			
		<script src="${request.contextPath}/static/assets/js/bootstrap.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/jquery-ui.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/bootbox.js"></script>
		<script src="${request.contextPath}/static/assets/js/spin.js"></script>
		<!-- ace scripts -->
		<script src="${request.contextPath}/static/assets/js/d3.v3.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/ace-elements.min.js"></script>
		<script src="${request.contextPath}/static/assets/js/ace.min.js"></script>
		<!-- validator scripts -->
		<script src="${request.contextPath}/static/assets/js/bootstrapValidator.min.js"></script>
		<!-- user scripts -->
		<script src="${request.contextPath}/static/assets/js/user/base.js"></script>
		<script type="text/javascript">
			d3.select(self.frameElement).style("height", "1150px");
			
			$(document).ready(function() {
			    var url = window.location.href;
			    console.log(url);
			    if( url.indexOf('#') < 0 ) {
			        window.location.replace(url + "#");
			    } else {
			        window.location.replace(url);
			    }
			});
			function dealCommodityMatch(obj){
				/*  竞品公司商品ID()  */
				var uuidValue = $("#commodityUuidId").val();
				/*  当前所选驴妈妈商品commodityId  */
				var checkedValue = $(obj).attr("data-value");
				/*  已经关联成功的驴妈妈商品commodityId  */
				var currentLinkedLvmmCommodityId = $("#currentLinkedLvmmCommodityId").val();
				if(currentLinkedLvmmCommodityId==checkedValue){
					bootbox.alert("<strong style='padding-left:200px'>已关联当前商品，不能重复关联！</strong>");
					return;
				}
				bootbox.confirm("<strong style='font-size:15px;'>确定关联的驴妈妈商品吗？</strong>",function(result){
					if(result){
						$.ajax({  
					          url: "${request.contextPath}/match/ticket/commodity/rel/commodityMatch?dataUUID="+uuidValue+"&lvmmCommodityID="+checkedValue,
					          type: 'GET',
					          async: false,  
					          success: function (data) { 
					              if(data.Success!=null){
					            	  $('#returnToMatchPage').click();
					            	 // bootbox.alert("<strong style='padding-left:200px'>"+data.Success+"</strong>",function(){$('#returnToMatchPage').click()});
					              } 
					              //alert(data.inputError);
					              if(data.errorMessage!=null){
					            	  bootbox.alert("<strong style='padding-left:120px'>"+data.errorMessage+"</strong>",function(){$('#returnToMatchPage').click()});
					              }
					 
					          },  
					          error: function (data) {  
					        	  bootbox.alert("<strong style='padding-left:200px'>商品关联失败！</strong>",function(){$('#returnToMatchPage').click()});  
					          }
					     }); 
					}
				});
			}
			
			function noCommodityMatch(){
				bootbox.confirm("<strong style='font-size:15px;'>确定没有可关联的驴妈妈商品吗？</strong>",function(result){
					if(result){
						 /*  竞品公司商品ID()  */
						 var uuidValue = $("#commodityUuidId").val();
			     	  	 $.ajax({  
					          url: "${request.contextPath}/match/ticket/commodity/rel/noCommodityMatch?commodityID="+uuidValue,  
					          type: 'GET',  
					          timeout: 12000,
					          async: false,  
					          cache: false,  
					          contentType: false,  
					          processData: false,
					          success: function (data) { 
					              if(data.Success!=null){
					            	  $('#returnToMatchPage').click();
					            	  //bootbox.alert("<strong style='padding-left:200px'>"+data.Success+"</strong>",function(){$('#returnToMatchPage').click()});
					              } 
					              //alert(data.inputError);
					              if(data.errorMessage!=null){
					            	  bootbox.alert("<strong style='padding-left:120px'>"+data.errorMessage+"</strong>",function(){$('#returnToMatchPage').click()});
					              } 
					              
					          },  
					          error: function (data) {  
					        	  bootbox.alert("<strong style='padding-left:200px'>更新无商品关联操作失败</strong>",function(){$('#returnToMatchPage').click()});  
					          }
					     });  
					     	  	
					}
				});
			}
			
			function priceSortClick(){
				/*  标识驴妈妈商品按价格排序  */
				$("#lmmCommoditySortType").val("true");
				/*  默认从第一页开始  */
				$("#searchForm").submit();
			}
			function commodityNameSortClick(){
				/*  标识驴妈妈商品按价格排序  */
				$("#lmmCommoditySortType").val("");
				/*  默认从第一页开始  */
				$("#searchForm").submit();
			}
		</script>
	
	</body>
</html>